{if $smarty.get.print != 1}
  {include file="header.tpl"}
{else}
  <table width="100%">
    <td width="33.33%"><img src="./images/shreeSava.jpg" /></td>
    <td width="33.33%" align="center"><img src="./images/shreeGanesh.jpg" /></td>
    <td width="33.33%" align="right"><img src="./images/shreeGelMataji.jpg" /></td>
  </table>
{/if}
<script type="text/javascript" src="./js/jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
  {if $doSubmit == 1}
    bookFunction();
  {/if}
  });
function deleteRow(bhatthiId)
{
  if(confirm("Warning: Are you sure?\nDeletion is permanent. Continue anyway."))
  {
    location.href = "deleteBhatthiBook.php?bhatthiId="+bhatthiId;
  }
}
function bookFunction(id)
{
  document.form.bdate .value="1";
  document.form.submit();
}
</script>

<form name="form" action="" method="post">
<input type="hidden" name="bdate" id="bdate" value="0" />
<center><b>{$l_bhatthiDetail}</b></center>
<div class="contentDiv">
  <table border="0" align="center" width="98%" cellspacing="0" cellpadding="2" >
  <tr>
    <td class="table1">
      {$l_partySelect} :
      <select name="party" onchange="bookFunction()">
        <option value="0">{$l_partySelect}</option>
        {html_options values=$party.id output=$party.name selected={$partyId}}
      </select>
    </td>
    <td class="table1">
    {if $doSubmit == 1}
      {$l_from} : {html_select_date prefix="fromDate" start_year="-2" end_year="+1" field_order="DMY" day_value_format="%02d" time={$fromDate}}
      {$l_to} : {html_select_date prefix="toDate" start_year="-2" end_year="+1" field_order="DMY" day_value_format="%02d" time={$toDate}}
    {/if}
      <input type="submit" name="submitBtn" value="{$l_find}" />
      {if $smarty.get.print!=1}
        <td class="table1"><a href="bhatthiDetail.php?print=1">Print</a></td>
      {else}
        &nbsp;
      {/if}
    </td>
  </tr>

  <tr class="table1" align="center">
      <th colspan="7">{$l_credit}</th>
  </tr>
  <tr align="center">
    <table border="1" align="center" width="95%" cellspacing="0" cellpadding="2">
      <tr class="table1">
        <th>{$l_date}</th>
        <th>{$l_particulars}</th>
        <th>grossWeight</th>
        <th>Ghat</th>
        <th>{$l_weight}</th>
        <th>{$l_touch}</th>
        <th>{$l_fine}</th>
        <th>{$l_qty}</th>
        <th>{$l_rate}</th>
        <th>{$l_amount}</th>
      </tr>
      <tr>
        <td style="border-right:1px solid;">&nbsp;</td>
        <td align="center" style="border-right:1px solid;">Opening</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td align="right" style="border-right:1px solid;">{if $opening.crWeight != 0}{$opening.crWeight|string_format:"%.0f"}{else}&nbsp;{/if}</td>
        <td align="right" style="border-right:1px solid;">{if $opening.crTouch != 0}{$opening.crTouch|string_format:"%.2f"}{else}&nbsp;{/if}</td>
        <td align="right" style="border-right:1px solid;">{if $openingFinalFineCr != 0}{$openingFinalFineCr|string_format:"%.0f"}{else}&nbsp;{/if}</td>
        <td align="right">{if $openingFinalAmountCr != 0}{$openingFinalAmountCr|string_format:"%.2f"}{else}&nbsp;{/if}</td>
      </tr>
      {section name=crSec loop=$bhatthiBookCr|@count}
        <tr>
          <td NOWRAP align="center" style="border-right:1px solid;">{$bhatthiBookCr[crSec].date|date_format:"%e-%b-%Y"}</td>
          <td align="center" style="border-right:1px solid;">{$bhatthiBookCr[crSec].particulars}</td>
          <td align="center" style="border-right:1px solid;">{if $bhatthiBookCr[crSec].grossWeight != 0}{$bhatthiBookCr[crSec].grossWeight|string_format:"%.2f"}{else}&nbsp;{/if}</td>
          <td align="center" style="border-right:1px solid;">{if $bhatthiBookCr[crSec].diffWeight != 0}{$bhatthiBookCr[crSec].diffWeight|string_format:"%.2f"}{else}&nbsp;{/if}</td>
          <td align="center" style="border-right:1px solid;">{if $bhatthiBookCr[crSec].weight != 0}{$bhatthiBookCr[crSec].weight|string_format:"%.2f"}{else}&nbsp;{/if}</td>
          <td align="center" style="border-right:1px solid;">{if $bhatthiBookCr[crSec].touch != 0}{$bhatthiBookCr[crSec].touch|string_format:"%.2f"}{else}&nbsp;{/if}</td>
          <td align="center" style="border-right:1px solid;">{if $bhatthiBookCr[crSec].fine != 0}{$bhatthiBookCr[crSec].fine|string_format:"%.0f"}{else}&nbsp;{/if}</td>
          <td align="center" style="border-right:1px solid;">{if $bhatthiBookCr[crSec].qty != 0}{$bhatthiBookCr[crSec].qty|string_format:"%.0f"}{else}&nbsp;{/if}</td>
          <td align="center" style="border-right:1px solid;">{if $bhatthiBookCr[crSec].rate != 0}{$bhatthiBookCr[crSec].rate|string_format:"%.0f"}{else}&nbsp;{/if}</td>
          <td align="center">{if $bhatthiBookCr[crSec].amount != 0}{$bhatthiBookCr[crSec].amount|string_format:"%.2f"}{else}&nbsp;{/if}</td>
        </tr>
      {/section}
      <tr><td colspan="10"><hr/></td></tr>
      <tr class="table1">
        <td colspan="5">&nbsp;</td>
        <td align="center"><b>Total</b></td>
        <td align="center">{$total.crFine|string_format:"%.0f"}</td>
         <td align="center">{$total.crQty|string_format:"%.0f"}</td>
         <td>&nbsp;</td>
        <td align="center">{$total.crAmount|string_format:"%.0f"}</td>
      </tr>
      <tr><td colspan="10"><b>&nbsp;{if $bhatthiCreditPrevFine >= 0} Total Debit Fine:{else} Total Credit Fine:{/if} {$bhatthiDebitPrevFine|string_format:"%.0f"}</b></td></tr> 
      <tr><td colspan="10"><b>&nbsp;{if $bhatthiCreditPrevAmount >= 0} Total Debit Amount:{else} Total Credit Amount:{/if}{$bhatthiDebitPrevAmount|string_format:"%.0f"}</b></td></tr>
    </table>
  </tr>
  </table>
</div>
</form>
{if $smarty.get.print != 1}
  {include file="footer.tpl"}
{/if}